Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • graph export, as(pdf) fails to add special characters in the graph legend if inside {fontface "...": ...}

    Hi, I am trying to export a plot where I include special characters in the legend while I also set the font face. The created graph looks excellent in the graph window, as well as in the exported PNG. However, the PDF export fails to expand special characters using the {&...} notation. The following code replicates the issue:
    Code:
    sysuse auto
    
    *this is okay in both pdf and png
    tw (sc mpg price if !foreign) (sc mpg price if foreign), leg(lab(1 `"{&Delta} Not Foreign"') label(2 `"{&Gamma} Foreign"'))
    gr export "C:/appl/stata_data/mpg_price.pdf", as(pdf) replace
    gr export "C:/appl/stata_data/mpg_price.png", as(png) replace
    
    *issue is here only in pdf
    tw (sc mpg price if !foreign) (sc mpg price if foreign), leg(lab(1 `"{fontface "Times New Roman":{&Delta} Not Foreign}"') label(2 `"{fontface "Bauhaus 93":{&Gamma} Foreign}"'))
    gr export "C:/appl/stata_data/mpg_price_fontface.pdf", as(pdf) replace
    gr export "C:/appl/stata_data/mpg_price_fontface.png", as(png) replace
    I have attached the exported figures. Does anyone know how to export to PDF correctly?
    PS: Uploading the PDF with the font face setting failed with the error message: `Ghostscript must be installed on the server to resize .pdf files. mpg_price_fontface.pdf.' This may also be related to the above issue, though I am not sure.
    Attached Files

  • #2
    Seems like a bug. I'm not sure that it's in Stata's end of things, though; it might be in the software (whatever it is) that Stata uses to export graphs to Portable Document Format files. I recommend reporting it to StataCorp, anyway.

    I don't know of a good workaround. Maybe others on the list do.

    In the meantime, you could try printing from the graph window to a PDF file. You could try exporting to a vector graphics file and from that converting to PDF somehow.

    Comment


    • #3
      Dear Joseph Coveney,

      Thank you for your reply. I will try reporting to the StataCorp. At the moment I will either avoid using the nested special characters or use other formats with no issues.

      Exporting manually from the graph window is not really an option for me, as I need to run a bunch of codes in a .do file at a time.

      Comment

      Working...
      X